package main

import (
	"encoding/json"
	"fmt"
)

func findJudge(n int, trust [][]int) int {
	inDegrees := make([]int, n+1)
	outDegrees := make([]int, n+1)
	for _, t := range trust {
		inDegrees[t[1]]++
		outDegrees[t[0]]++
	}
	for i := 1; i <= n; i++ {
		if inDegrees[i] == n-1 && outDegrees[i] == 0 {
			return i
		}
	}
	return -1
}


func main() {
	var n int
	var trustInput string
	if _, err := fmt.Scanf("%d\n%s", &n, &trustInput); err != nil {
		println("err:", err)
		return
	}

	trust := make([][]int, 0)
	if gridJsonErr := json.Unmarshal([]byte(trustInput), &trust); gridJsonErr != nil {
		println("gridJsonErr: ", gridJsonErr)
		return
	}

	println(findJudge(n, trust))
}